home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / Amiga_Mail_Vol2 / Archives / Plain / jf91 / genlock.txt < prev   
Encoding:
Text File  |  1991-04-15  |  42.8 KB  |  619 lines

  1. (c)  Copyright 1991 Commodore-Amiga, Inc.   All rights reserved.
  2. The information contained herein is subject to change without notice,
  3. and is provided "as is" without warranty of any kind, either expressed
  4. or implied.  The entire risk as to the use of this information is
  5. assumed by the user.
  6.  
  7.  
  8.  
  9.  
  10.  
  11. Using the ECS Genlocking Features
  12.  
  13.  
  14. By Ewout Walraven
  15.  
  16. The ECS Denise chip (8373-R2a), coupled with the release 2.0
  17. graphics.library, opens up a whole new set of genlocking
  18. possibilities.  Unlike the old Denise, whose only genlocking ability
  19. allowed keying1 on color register zero, the ECS Denise allows keying
  20. on any color register.  Also, the ECS Denise allows keying on any
  21. bitplane of the ViewPort being genlocked.  With the ECS Denise, the
  22. border area surrounding the display can be made transparent (always
  23. passes video) or opaque (overlays using color 0).  All the new
  24. features are set individually for each ViewPort.  These features can
  25. be used in conjunction with each other, making interesting scenarios
  26. possible.  These hardware capabilities and the software support in
  27. release 2.0 offer new challenges for video oriented software.
  28.  
  29.  
  30. VideoControl()
  31.  
  32. The graphics.library function VideoControl() modifies the operation of
  33. a ViewPort's ColorMap and also reports on the ColorMap's status. 
  34.  
  35. error = BOOL VideoControl( struct ColorMap *colormap,
  36.                            struct TagItem *videocommandstagarray );
  37.  
  38. Using VideoControl(), a program can enable, disable, or obtain the
  39. state of a ViewPort's genlocking features.  It returns NULL if no
  40. error occurred.  The function uses a tag based interface.
  41.  
  42. This article is concerned with the following VideoControl() tags:
  43.  
  44. VTAG_BITPLANEKEY_GET
  45. VTAG_BITPLANEKEY_SET
  46. VTAG_BITPLANEKEY_CLR
  47. VTAG_CHROMA_PLANE_GET
  48. VTAG_CHROMA_PLANE_SET
  49. VTAG_BORDERBLANK_GET
  50. VTAG_BORDERBLANK_SET
  51. VTAG_BORDERBLANK_CLR
  52. VTAG_BORDERNOTRANS_GET
  53. VTAG_BORDERNOTRANS_SET
  54. VTAG_BORDERNOTRANS_CLR
  55. VTAG_CHROMAKEY_GET
  56. VTAG_CHROMAKEY_SET
  57. VTAG_CHROMAKEY_CLR
  58. VTAG_CHROMAPEN_GET
  59. VTAG_CHROMAPEN_SET
  60. VTAG_CHROMAPEN_CLR
  61.  
  62. See <graphics/videocontrol.h> for a complete list of all the available
  63. tags. 
  64.  
  65. VTAG_BITPLANEKEY_GET is used to find out the status of the bitplane
  66. keying mode.  VTAG_BITPLANEKEY_SET and VTAG_BITPLANEKEY_CLR activate
  67. and deactivate bitplane keying mode.  If bit plane key mode is on,
  68. genlocking will key on the bits set in a specific bitplane from the
  69. ViewPort (the specific bitplane is set with a different tag).  The
  70. data portion of these tags is NULL.
  71.  
  72.  
  73. For inquiry commands like VTAG_BITPLANEKEY_GET (tags ending in _GET),
  74. VideoControl() changes the _GET tag ID to the corresponding _SET or
  75. _CLR tag ID, reflecting the current state.  For example, when passed
  76. the following tag array:
  77.  
  78. struct TagItem videocommands[] = 
  79. {
  80.     { VTAG_BITPLANEKEY_GET, NULL},
  81.     {VTAG_END_CM, NULL}
  82. };
  83.  
  84. VideoControl() changes the VTAG_BITPLANEKEY_GET ID to
  85. VTAG_BITPLANEKEY_SET if bit plane keying is currently on, or to
  86. VTAG_BITPLANEKEY_CLR if bit plane keying is off.  In both of these
  87. cases, VideoControl() only uses the tag's ID, ignoring the tag's data
  88. field.
  89.  
  90. The VTAG_CHROMA_PLANE_GET tag returns the number of the bitplane keyed
  91. on when bit plane keying mode is on.  VideoControl() changes the tag's
  92. data value to the bitplane number.  VTAG_CHROMA_PLANE_SET sets the
  93. bitplane number to the tag's data value.
  94.  
  95. VTAG_BORDERBLANK_GET is used to obtain the border blank mode status.
  96. This tag works exactly like VTAG_BITPLANEKEY_GET.  VideoControl()
  97. changes the tag's ID to reflect the current border blanking state.
  98. VTAG_BORDERBLANK_SET and VTAG_BORDERBLANK_CLR activate and deactivate
  99. border blanking.  If border blanking is on, the Amiga will not display
  100. anything in its display border, allowing an external video signal to
  101. show through the border area.  On the Amiga display, the border
  102. appears black.  The data portion of these tags is NULL.
  103.  
  104. Respectively, the VTAG_BORDERNOTRANS_GET, VTAG_BORDERNOTRANS_SET, and
  105. VTAG_BORDERNOTRANS_CLR tags are used to obtain the status of
  106. BorderNoTransparent mode, and to activate and to deactivate this mode.
  107. If set, the Amiga display's border will overlay external video with
  108. the color in register 0.  Because border blanking mode takes
  109. precedence over BorderNoTransparent mode, setting BorderNoTransparent
  110. has no effect if border blanking is on.  The data portion of these
  111. tags is NULL.
  112.  
  113. Respectively, the VTAG_CHROMAKEY_GET, VTAG_CHROMAKEY_SET, and
  114. VTAG_CHROMAKEY_CLR tags are used to obtain the status of chroma keying
  115. mode, and to activate and deactivate chroma keying mode.  If set, the
  116. genlock will key on colors from specific color registers (the specific
  117. color registers are set using a different tag).  If chroma keying is
  118. not set, the genlock will key on color register 0.  The data portion
  119. of these tags is NULL.
  120.  
  121. VTAG_CHROMAPEN_GET obtains the chroma keying status of an individual
  122. color register.  The tag's data field contains the register number.
  123. Like the other _GET tags, VideoControl() changes the tag ID to one
  124. reflecting the current state.  VTAG_CHROMAPEN_SET and
  125. VTAG_CHROMAPEN_CLR activate and deactivate chroma keying for each
  126. individual color register.  chroma keying can be active for more than
  127. one register.  By turning off border blanking and activating chroma
  128. keying mode, but turning off chroma keying for each color register, a
  129. program can overlay every part of an external video source, completely
  130. blocking it out.
  131.  
  132. After using VideoControl() to set values in the ColorMap, the
  133. ColorMap's ViewPort has to be rebuilt with MakeVPort(), MrgCop(), and
  134. LoadView(), so the changes can take effect.  A program that uses a
  135. screen's ViewPort rather than its own ViewPort should use the
  136. Intuition functions MakeScreen() and RethinkDisplay() to make the
  137. display changes take effect.
  138.  
  139. The following example, genlockdemo.c, shows how to add genlock support
  140. for an Intuition screen.
  141.  
  142.  
  143.  
  144.  
  145. /* genlockdemo.c - Amiga Mail Jan/Feb '91 Genlock VideoControl example.
  146. ** compiled with:
  147. **   LC -b1 -cfistq -v genlockdemo.c
  148. **   Blink FROM LIB:c.o,genlockdemo.o TO genlockdemo LIBRARY LIB:LC.lib,LIB:Amiga.lib
  149. */
  150. #include <exec/types.h>
  151. #include <exec/memory.h>
  152. #include <graphics/gfxbase.h>
  153. #include <graphics/displayinfo.h>
  154. #include <graphics/VideoControl.h>
  155. #include <graphics/view.h>
  156. #include <intuition/intuition.h>
  157. #include <intuition/screens.h>
  158. #include <libraries/gadtools.h>
  159.  
  160. #include <clib/alib_stdio_protos.h>
  161. #include <clib/intuition_protos.h>
  162. #include <clib/graphics_protos.h>
  163. #include <clib/exec_protos.h>
  164. #include <clib/gadtools_protos.h>
  165.  
  166. /* Some gadget ID's */
  167. #define BORDERBLANK_ID          16
  168. #define BORDERNOTRANS_ID        17
  169. #define BITPLANEKEY_ID          18
  170. #define CHROMAPLANE_ID          19
  171. #define CHROMAKEY_ID            20
  172.  
  173. /* Some protos */
  174. VOID main(VOID);
  175. BOOL CheckPAL(STRPTR);
  176. UWORD strlen(STRPTR);
  177.  
  178. struct IntuitionBase *IntuitionBase;
  179. struct GfxBase *GfxBase;
  180. struct Library *GadToolsBase;
  181.  
  182.  
  183. /* Give me 3D look window (I'll use a quiet screen */
  184. static UWORD dri_Pens[] =
  185. {0, 1, 1, 2, 1, 3, 1, 0, 3, ~0};
  186.  
  187. /* Just a demo, set everything to topaz 80. */
  188. static struct TextAttr Topaz80 = {"topaz.font", 8, 0, 0,};
  189.  
  190.  
  191. /* strings for cycle gadget */
  192. static STRPTR ChPlaneText[] = {"Plane 0", "Plane 1", "Plane 2", "Plane 3", NULL};
  193.  
  194.  
  195. struct EasyStruct failedES = {sizeof(struct EasyStruct), 0, "GenlockDemo", "%s", "Continue",};
  196.  
  197.  
  198. VOID main(VOID)
  199. {
  200.         struct Screen *genscreen;
  201.         struct Window *controlwindow;
  202.         struct Gadget *glist, *gadget, *hitgadget;
  203.         struct ViewPort *vp;
  204.         void *vi;
  205.         struct NewGadget ng;
  206.         struct IntuiMessage *imsg;
  207.         struct TagItem vtags[24];
  208.         ULONG GadgetPtrs[21];
  209.         ULONG iclass, icode;
  210.         STRPTR gtextbuffer, gtextptr;
  211.         UWORD i, j;
  212.         BOOL ABORT = FALSE;
  213.         BOOL IsPAL;
  214.         /* Fails silently if < V37 */
  215.         if (IntuitionBase = OpenLibrary("intuition.library", 37)) 
  216.         {
  217.                 if (GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 37)) 
  218.                 {
  219.                         if (GadToolsBase = OpenLibrary("gadtools.library", 37)) 
  220.                         {
  221.                                 if (GfxBase->ChipRevBits0 & GFXF_HR_DENISE) 
  222.                                 {
  223.                                         /* Check if the user happens to prefer PAL or if this is a true PAL System. */
  224.                                         IsPAL = CheckPAL("Workbench");
  225.                                         /* buffer for some gadget text */
  226.                                         if (gtextbuffer = AllocMem(256, MEMF_CLEAR)) 
  227.                                         {
  228.                                                 gtextptr = gtextbuffer;
  229.  
  230.                                                 /* Open a 'standard' HIRES screen */
  231.                                                 if (genscreen = OpenScreenTags(NULL, SA_Pens, (ULONG) dri_Pens,
  232.                                                 SA_DisplayID, HIRES_KEY,
  233.                                                 SA_Depth, 4,
  234.                                                 /* Give me a lot of border */
  235.                                                 SA_Width, 640,
  236.                                                 SA_Height, (IsPAL) ? 256 : 200,
  237.                                                 SA_Overscan, 0,
  238.                                                 /* Hold the titlebar, please */
  239.                                                 SA_Quiet, TRUE,
  240.                                                 /* Give me sysfont 0 as default rastport font. */
  241.                                                 SA_SysFont, 1,
  242.                                                 TAG_DONE)) 
  243.                                                 {
  244.  
  245.                                                         /* Blast some colorbars in screen's rastport, leave some color 0 gaps */
  246.                                                         for (i = 0, j = 0; i < 16; i++, j += 40) 
  247.                                                         {
  248.                                                                 SetAPen(&(genscreen->RastPort), i);
  249.                                                                 RectFill(&(genscreen->RastPort), (j + 1), 0, (j + 30), (IsPAL) ? 255 : 199);
  250.  
  251.                                                         }
  252.                                                         /* A line to show where borders start */
  253.                                                         SetAPen(&(genscreen->RastPort), 5);
  254.                                                         Move(&(genscreen->RastPort),0,0);
  255.                                                         Draw(&(genscreen->RastPort),genscreen->Width-1,0);
  256.                                                         Draw(&(genscreen->RastPort),genscreen->Width-1,genscreen->Height-1);
  257.                                                         Draw(&(genscreen->RastPort),0,genscreen->Height-1);
  258.                                                         Draw(&(genscreen->RastPort),0,0);
  259.  
  260.                                                         /* Open a restricted window, no draggin, sizing, just closing.
  261.                                                          * (don't want to refresh screen)
  262.                                                          */
  263.                                                         if (controlwindow = OpenWindowTags(NULL, WA_Title, (ULONG) "VideoControl",
  264.                                                         WA_Left, 210,
  265.                                                         WA_Top, 20,
  266.                                                         WA_Width, 220,
  267.                                                         WA_Height, 150,
  268.                                                         WA_CustomScreen, genscreen,
  269.                                                         WA_Flags, WFLG_CLOSEGADGET | WFLG_ACTIVATE | WFLG_NOCAREREFRESH,
  270.                                                         WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_GADGETUP,
  271.                                                         TAG_DONE)) 
  272.                                                         {
  273.  
  274.                                                                 /* Ok, got a window, lets make some gadgets */
  275.                                                                 if (vi = GetVisualInfo(genscreen, TAG_END)) 
  276.                                                                 {
  277.                                                                         if (gadget = CreateContext(&glist)) 
  278.                                                                         {
  279.                                                                                 ng.ng_TextAttr = &Topaz80;
  280.                                                                                 ng.ng_VisualInfo = vi;
  281.                                                                                 ng.ng_Flags = PLACETEXT_LEFT | NG_HIGHLABEL;
  282.  
  283.                                                                                 ng.ng_LeftEdge = controlwindow->BorderLeft + 120;
  284.                                                                                 ng.ng_TopEdge = controlwindow->BorderTop + 2;
  285.                                                                                 ng.ng_Width = 12;
  286.                                                                                 ng.ng_Height = 12;
  287.                                                                                 ng.ng_GadgetText = "BORDERBLANK";
  288.                                                                                 ng.ng_GadgetID = BORDERBLANK_ID;
  289.                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  290.                                                                                 GadgetPtrs[BORDERBLANK_ID] = (ULONG) gadget;
  291.  
  292.                                                                                 ng.ng_TopEdge += gadget->Height + 2;
  293.                                                                                 ng.ng_GadgetText = "BORDERNOTRANS";
  294.                                                                                 ng.ng_GadgetID = BORDERNOTRANS_ID;
  295.                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  296.                                                                                 GadgetPtrs[BORDERNOTRANS_ID] = (ULONG) gadget;
  297.  
  298.                                                                                 ng.ng_TopEdge += gadget->Height + 2;
  299.                                                                                 ng.ng_GadgetText = "CHROMAKEY";
  300.                                                                                 ng.ng_GadgetID = CHROMAKEY_ID;
  301.                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  302.                                                                                 GadgetPtrs[CHROMAKEY_ID] = (ULONG) gadget;
  303.  
  304.                                                                                 ng.ng_TopEdge += gadget->Height + 2;
  305.                                                                                 ng.ng_GadgetText = "BITPLANEKEY";
  306.                                                                                 ng.ng_GadgetID = BITPLANEKEY_ID;
  307.                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  308.                                                                                 GadgetPtrs[BITPLANEKEY_ID] = (ULONG) gadget;
  309.  
  310.                                                                                 ng.ng_TopEdge += gadget->Height + 2;
  311.                                                                                 ng.ng_Width = 90;
  312.                                                                                 ng.ng_GadgetText = "CHROMAPLANE";
  313.                                                                                 ng.ng_GadgetID = CHROMAPLANE_ID;
  314.                                                                                 gadget = CreateGadget(CYCLE_KIND, gadget, &ng, GTCY_Labels, (ULONG) ChPlaneText,
  315.                                                                                                       TAG_END);
  316.                                                                                 GadgetPtrs[CHROMAPLANE_ID] = (ULONG) gadget;
  317.  
  318.                                                                                 ng.ng_TopEdge += gadget->Height + 20;
  319.                                                                                 ng.ng_Width = 12;
  320.                                                                                 ng.ng_Flags = PLACETEXT_ABOVE | NG_HIGHLABEL;
  321.                                                                                 for (j = 0; j < 2; j++) 
  322.                                                                                 {
  323.                                                                                         for (i = 0; i < 8; i++) 
  324.                                                                                         {
  325.                                                                                                 ng.ng_LeftEdge = controlwindow->BorderLeft + 2 + (i * gadget->Width);
  326.                                                                                                 sprintf(gtextptr, "%ld", i + (j * 8));
  327.                                                                                                 ng.ng_GadgetText = gtextptr;
  328.                                                                                                 ng.ng_GadgetID = i + (j * 8);
  329.                                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  330.                                                                                                 GadgetPtrs[i] = (ULONG) gadget;
  331.                                                                                                 gtextptr += strlen(gtextptr) + 1;
  332.                                                                                         }
  333.                                                                                         ng.ng_TopEdge += gadget->Height;
  334.                                                                                         ng.ng_Flags = PLACETEXT_BELOW | NG_HIGHLABEL;
  335.                                                                                 }
  336.                                                                                 AddGList(controlwindow, glist, -1, -1, NULL);
  337.                                                                                 RefreshGList(glist, controlwindow, NULL, -1);
  338.                                                                                 GT_RefreshWindow(controlwindow, NULL);
  339.  
  340.                                                                                 /* Finally, a window with some gadgets...
  341.                                                                                  *
  342.                                                                                  * Get the current genlock state.
  343.                                                                                  * Obviously I already know what the settings will be (all off),
  344.                                                                                  * since I opened the screen myself. Do it just to show how to get them.
  345.                                                                                  */
  346.  
  347.                                                                                 vp = &(genscreen->ViewPort);
  348.  
  349.  
  350.  
  351.  
  352.                                                                                 /* Is borderblanking on? */
  353.                                                                                 vtags[0].ti_Tag = VTAG_BORDERBLANK_GET;
  354.                                                                                 vtags[0].ti_Data = NULL;
  355.                                                                                 /* Is bordertransparent set */
  356.                                                                                 vtags[1].ti_Tag = VTAG_BORDERNOTRANS_GET;
  357.                                                                                 vtags[1].ti_Data = NULL;
  358.                                                                                 /* Key on bitplane? */
  359.                                                                                 vtags[2].ti_Tag = VTAG_BITPLANEKEY_GET;
  360.                                                                                 vtags[2].ti_Tag = NULL;
  361.                                                                                 /* Get plane which is used to key on */
  362.                                                                                 vtags[3].ti_Tag = VTAG_CHROMA_PLANE_GET;
  363.                                                                                 vtags[3].ti_Data = NULL;
  364.                                                                                 /* Chromakey overlay on? */
  365.                                                                                 vtags[4].ti_Tag = VTAG_CHROMAKEY_GET;
  366.                                                                                 vtags[4].ti_Data = NULL;
  367.  
  368.                                                                                 for (i = 0; i < 16; i++) 
  369.                                                                                 {
  370.                                                                                         /* Find out which colors overlay */
  371.                                                                                         vtags[i + 5].ti_Tag = VTAG_CHROMA_PEN_GET;
  372.                                                                                         vtags[i + 5].ti_Data = i;
  373.                                                                                 }
  374.  
  375.                                                                                 /* Indicate end of tag array */
  376.                                                                                 vtags[21].ti_Tag = VTAG_END_CM;
  377.                                                                                 vtags[21].ti_Data = NULL;
  378.  
  379.                                                                                 /* And send the commands. On return the Tags themself will
  380.                                                                                  * indicate the genlock settings for this ViewPort's ColorMap.
  381.                                                                                  */
  382.                                                                                 VideoControl(vp->ColorMap, vtags);
  383.  
  384.                                                                                 /* And initialize gadgets, according to genlock settings */
  385.                                                                                 if (vtags[0].ti_Tag == VTAG_BORDERBLANK_SET)
  386.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[BORDERBLANK_ID],
  387.                                                                                                           controlwindow, NULL, GTCB_Checked, TRUE, TAG_DONE);
  388.                                                                                 if (vtags[1].ti_Tag == VTAG_BORDERNOTRANS_SET)
  389.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[BORDERNOTRANS_ID],
  390.                                                                                                           controlwindow, NULL, GTCB_Checked, TRUE, TAG_DONE);
  391.                                                                                 if (vtags[2].ti_Tag == VTAG_BITPLANEKEY_SET)
  392.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[BITPLANEKEY_ID], 
  393.                                                                                                           controlwindow, NULL, GTCB_Checked, TRUE, TAG_DONE);
  394.                                                                                 if (vtags[3].ti_Tag == VTAG_CHROMA_PLANE_SET)
  395.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[CHROMAPLANE_ID],
  396.                                                                                                           controlwindow, NULL, GTCY_Active, vtags[3].ti_Data,
  397.                                                                                                           TAG_DONE);
  398.                                                                                 if (vtags[4].ti_Tag == VTAG_CHROMAKEY_SET)
  399.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[CHROMAKEY_ID],
  400.                                                                                                           controlwindow, NULL, GTCB_Checked, TRUE, TAG_DONE);
  401.                                                                                 for (i = 0; i < 16; i++) 
  402.                                                                                 {
  403.                                                                                         if (vtags[i + 5].ti_Tag == VTAG_CHROMA_PEN_SET)
  404.                                                                                                 GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[i], 
  405.                                                                                                                   controlwindow, NULL, GTCB_Checked, TRUE);
  406.                                                                                 }
  407.  
  408.                                                                                 /* Will only send single commands from here on. */
  409.                                                                                 vtags[1].ti_Tag = VTAG_END_CM;
  410.  
  411.                                                                                 /* Get user input. */
  412.                                                                                 do 
  413.                                                                                 {
  414.                                                                                         WaitPort(controlwindow->UserPort);
  415.                                                                                         while (imsg = GT_GetIMsg(controlwindow->UserPort)) {
  416.                                                                                                 iclass = imsg->Class;
  417.                                                                                                 icode = imsg->Code;
  418.                                                                                                 hitgadget = (struct Gadget *) imsg->IAddress;
  419.                                                                                                 GT_ReplyIMsg(imsg);
  420.  
  421.  
  422.  
  423.                                                                                                 switch (iclass) 
  424.                                                                                                 {
  425.                                                                                                 case GADGETUP:
  426.                                                                                                         if (hitgadget->GadgetID < 16) 
  427.                                                                                                         {
  428.                                                                                                                 /* Set colorkey */
  429.                                                                                                                 if (hitgadget->Flags & SELECTED)
  430.                                                                                                                         vtags[0].ti_Tag = VTAG_CHROMA_PEN_SET;
  431.                                                                                                                 /* Clear colorkey */
  432.                                                                                                                 else
  433.                                                                                                                         vtags[0].ti_Tag = VTAG_CHROMA_PEN_CLR;
  434.                                                                                                                 vtags[0].ti_Data = hitgadget->GadgetID;
  435.                                                                                                         } 
  436.                                                                                                         else 
  437.                                                                                                         {
  438.                                                                                                                 switch (hitgadget->GadgetID) {
  439.                                                                                                                 case BORDERBLANK_ID:
  440.                                                                                                                         /* Set borderblanking on */
  441.                                                                                                                         if (hitgadget->Flags & SELECTED)
  442.                                                                                                                                 vtags[0].ti_Tag =
  443.                                                                                                                                     VTAG_BORDERBLANK_SET;
  444.                                                                                                                         /* Turn borderblanking off */
  445.                                                                                                                         else
  446.                                                                                                                                 vtags[0].ti_Tag =
  447.                                                                                                                                     VTAG_BORDERBLANK_CLR;
  448.                                                                                                                         break;
  449.                                                                                                                 case BORDERNOTRANS_ID:
  450.                                                                                                                         /* Set bordertransparency on */
  451.                                                                                                                         if (hitgadget->Flags & SELECTED)
  452.                                                                                                                                 vtags[0].ti_Tag =
  453.                                                                                                                                     VTAG_BORDERNOTRANS_SET;
  454.                                                                                                                         /* Turn bordertransparency off */
  455.                                                                                                                         else
  456.                                                                                                                                 vtags[0].ti_Tag =
  457.                                                                                                                                     VTAG_BORDERNOTRANS_CLR;
  458.                                                                                                                         break;
  459.                                                                                                                 case BITPLANEKEY_ID:
  460.                                                                                                                         /* Key on current selected bitplane
  461.                                                                                                                          * (chromaplane) */
  462.                                                                                                                         if (hitgadget->Flags & SELECTED)
  463.                                                                                                                                 vtags[0].ti_Tag =
  464.                                                                                                                                     VTAG_BITPLANEKEY_SET;
  465.                                                                                                                         /* Turn bitplane keying off */
  466.                                                                                                                         else
  467.                                                                                                                                 vtags[0].ti_Tag =
  468.                                                                                                                                     VTAG_BITPLANEKEY_CLR;
  469.                                                                                                                         break;
  470.                                                                                                                 case CHROMAPLANE_ID:
  471.                                                                                                                         /* Set plane to key on */
  472.                                                                                                                         vtags[0].ti_Tag = VTAG_CHROMA_PLANE_SET;
  473.                                                                                                                         vtags[0].ti_Data = icode;
  474.                                                                                                                         break;
  475.                                                                                                                 case CHROMAKEY_ID:
  476.                                                                                                                         /* Set chromakey overlay on */
  477.                                                                                                                         if (hitgadget->Flags & SELECTED)
  478.                                                                                                                                 vtags[0].ti_Tag = VTAG_CHROMAKEY_SET;
  479.                                                                                                                         /* Turn chromakey overlay off */
  480.                                                                                                                         else
  481.                                                                                                                                 vtags[0].ti_Tag = VTAG_CHROMAKEY_CLR;
  482.                                                                                                                         break;
  483.                                                                                                                 }
  484.                                                                                                         }
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.                                                                                                         /* send video command */
  493.                                                                                                         VideoControl(vp->ColorMap, vtags);
  494.                                                                                                         /* Now use MakeScreen() and RethinkDisplay()
  495.                                                                                                          * to make the VideoControl changes 
  496.                                                                                                          * take effect.  If we were using our own
  497.                                                                                                          * Viewport rather than borrowing one from
  498.                                                                                                          * a screen, we would instead do:
  499.                                                                                                                      *   MakeVPort(ViewAddress(),vp);
  500.                                                                                                          *   MrgCop(ViewAddress());
  501.                                                                                                          *   LoadView(ViewAddres());
  502.                                                                                                          */ 
  503.                                                                                                         MakeScreen(genscreen);
  504.                                                                                                         RethinkDisplay();
  505.                                                                                                         break;
  506.  
  507.                                                                                                 case CLOSEWINDOW:
  508.                                                                                                         /* Get out of here */
  509.                                                                                                         ABORT = TRUE;
  510.                                                                                                         break;
  511.                                                                                                 }
  512.                                                                                         }
  513.                                                                                 } 
  514.                                                                                 while (ABORT == FALSE);
  515.  
  516.                                                                                 RemoveGList(controlwindow, glist, -1);
  517.                                                                                 FreeGadgets(glist);
  518.                                                                         } 
  519.                                                                         else
  520.                                                                                 EasyRequest(NULL, &failedES, NULL, "Can't create gadget context");
  521.                                                                         FreeVisualInfo(vi);
  522.                                                                 } 
  523.                                                                 else
  524.                                                                         EasyRequest(NULL, &failedES, NULL, "Can't get visual info");
  525.                                                                 CloseWindow(controlwindow);
  526.                                                         } 
  527.                                                         else
  528.                                                                 EasyRequest(NULL, &failedES, NULL, "Can't open window");
  529.                                                         CloseScreen(genscreen);
  530.                                                 } 
  531.                                                 else
  532.                                                         EasyRequest(NULL, &failedES, NULL, "Can't open screen");
  533.                                                 FreeMem(gtextbuffer, 256);
  534.                                         } 
  535.                                         else
  536.                                                 EasyRequest(NULL, &failedES, NULL, "Out of memory");
  537.                                 } 
  538.                                 else
  539.                                         EasyRequest(NULL, &failedES, NULL, "Requires ECS");
  540.                                 CloseLibrary(GadToolsBase);
  541.                         }
  542.                         CloseLibrary((struct Library *) GfxBase);
  543.                 }
  544.                 CloseLibrary(IntuitionBase);
  545.         }
  546. }
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559. BOOL CheckPAL(STRPTR screenname)
  560. {
  561.         struct Screen *screen;
  562.         ULONG modeID = LORES_KEY;
  563.         struct DisplayInfo displayinfo;
  564.         BOOL IsPAL;
  565.  
  566.         if (GfxBase->LibNode.lib_Version >= 36) 
  567.         {
  568.         /*
  569.          * We got V36, so lets use the new calls to find out what
  570.          * kind of videomode the user (hopefully) prefers.
  571.          */
  572.     
  573.                 if (screen = LockPubScreen(screenname)) 
  574.                 {
  575.                         /*
  576.                          * Use graphics.library/GetVPModeID() to get the ModeID of the specified screen.
  577.                          * Will use the default public screen (Workbench most of the time) if NULL It is
  578.                          * _very_ unlikely that this would be invalid, heck it's impossible.
  579.                          */
  580.                         if ((modeID = GetVPModeID(&(screen->ViewPort))) != INVALID_ID) 
  581.                         {
  582.                                 /*
  583.                                  * If the screen is in VGA mode, we can't tell whether the system is PAL or NTSC. So
  584.                                  * to be fullproof we fall back to the displayinfo of the default.monitor by
  585.                                  * inquiring about just the LORES_KEY displaymode if we don't know. The
  586.                                  * default.monitor reflects the initial video setup of the system, thus is an alias
  587.                                  * for either ntsc.monitor or pal.monitor. We only use the displaymode of the
  588.                                  * specified public screen if it's display mode is PAL or NTSC and NOT the default.
  589.                                  */
  590.  
  591.                                 if (!((modeID & MONITOR_ID_MASK) == NTSC_MONITOR_ID ||
  592.                                       (modeID & MONITOR_ID_MASK) == PAL_MONITOR_ID))
  593.                                         modeID = LORES_KEY;
  594.                         }
  595.                         UnlockPubScreen(NULL, screen);
  596.                 } /* if fails modeID = LORES_KEY. Can't lock screen, so fall back on default monitor. */
  597.     
  598.                 if (GetDisplayInfoData(NULL, (UBYTE *) & displayinfo,
  599.                     sizeof(struct DisplayInfo), DTAG_DISP, modeID)) 
  600.                 {
  601.                         if (displayinfo.PropertyFlags & DIPF_IS_PAL)
  602.                             IsPAL = TRUE;
  603.                         else
  604.                             IsPAL = FALSE;  /* Currently the default monitor is always either
  605.                                              * PAL or NTSC.
  606.                                              */
  607.                 }
  608.         } 
  609.         else /* < V36. The enhancements to the videosystem in V36 cannot be better expressed than
  610.                 * with the simple way to determine PAL in V34.
  611.                 */
  612.                 IsPAL= (GfxBase->DisplayFlags & PAL) ? TRUE : FALSE;
  613.     
  614.         return(IsPAL);
  615. }
  616.  
  617.  
  618.  
  619.